package com.nanhang.controller;

import com.nanhang.common.util.PageResult;
import com.nanhang.common.util.Result;
import com.nanhang.entity.Studenttable;
import com.nanhang.service.IStudentService;
import com.nanhang.vo.StudentVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController {

	@Autowired
	private IStudentService studentService;

	@RequestMapping("/list")
	public Result getStudent() {
		return Result.ok().data("list",studentService.list());
	}

	@GetMapping("/findByPage/{page}/{pageSize}")
	public Result findByPage(@PathVariable("page") Integer page,
							 @PathVariable("pageSize") Integer pageSize) {
		PageResult<Studenttable> pr = studentService.findByPage(page,pageSize);
		return Result.ok().data("pr",pr);
	}
	@PostMapping("/search/{page}/{pageSize}")
	public Result search(@PathVariable("page") Integer page,
						 @PathVariable("pageSize") Integer pageSize,
						 @RequestBody(required = false) StudentVO vo){
		PageResult<Studenttable> pr = studentService.search(page,pageSize,vo);
		return Result.ok().data("pr",pr);
	}
}
